package org.jsola.hr.web;

import com.alibaba.fastjson.JSON;
import org.jsola.hr.dto.attendrule.*;
import org.jsola.hr.dto.attendschedule.*;

import java.util.ArrayList;
import java.util.List;

public class MyBean {

//    public static void main(String[] args) {
//
//        AttendRuleAddDTO attendRuleAddDTO = new AttendRuleAddDTO();
//
//        // 方案名称
//        String planName = "工作日考勤规则一";
//        // 方案类型 ; 1-固定时间上下班,2-按班次上下班,3-自由上下班
//        int planType = 1;
//        // 打卡部门
//        List<AttendRuleDeptAddDTO> deptList = getDeptList();
//        // 打卡人员
//        List<AttendRuleStaffAddDTO> staffList = getStaffList();
//        // 白名单
//        List<AttendRuleWhitelistAddDTO> whitelist = getWhitelist();
//        // 汇报对象
//        List<AttendRuleReportAddDTO> reportList = getReportList();
//        // 打卡地点-位置
//        List<AttendRuleLocationAddDTO> locationList = getLocationList();
//        // 打卡地点-wifi
//        List<AttendRuleWifiAddDTO> wifiList = getWifiList();
//        // 打卡时间
//        List<AttendRulePunchTimeAddDTO> punchTimeList = getPunchTimeList();
//        // 特殊日期-必须打卡的日期
//        List<NeedPunchDateAddDTO> needPunchDateList = getNeedPunchDateList();
//        // 特殊日期-不必打卡的日期
//        List<NoNeedPunchDateAddDTO> noNeedPunchDateList = getNoNeedPunchDateList();
//        // 加班规则 1-以加班申请为准,2-以打卡时间为准,3-以加班申请核算打卡记录
//        int overtimeRule = 1;
//        // 是否同步中国节假日不能为空
//        int isSynchLegalHoliday = 0;
//        // 是否手机提醒;1-是,0-否
//        int isRemind = 1;
//        // 上班前x分钟
//        int remindBefore = 0;
//        // 下班后x分钟
//        int remindAfter = 0;
//        // 员工打卡时必须拍照
//        int isTakePhoto = 0;
//        // 只能拍照
//        int isOnlyPhoto = 0;
//        // 范围外打卡
//        int punchRange = 1;
//        // 是否补卡申请
//        int isMakeUp = 0;
//        // 每月不高于x下次
//        int maxMakeUpCounts = 0;
//        // 生效时间
//        int takeEffect = 0;
//
//        attendRuleAddDTO.setCompanyId("xxxxx");
//        // 方案名称
//        attendRuleAddDTO.setPlanName(planName);
//        // 规则类型不能为空 (1-固定时间上下班,2-按班次上下班,3-自由上下班)
//        attendRuleAddDTO.setPlanType(planType);
//        // 打卡部门
//        attendRuleAddDTO.setDeptList(deptList);
//        // 打卡人员
//        attendRuleAddDTO.setStaffList(staffList);
//        // 白名单
//        attendRuleAddDTO.setWhitelist(whitelist);
//        // 汇报对象
//        attendRuleAddDTO.setReportList(reportList);
//        // 打卡地点-位置
//        attendRuleAddDTO.setLocationList(locationList);
//        // 打卡地点-wifi
//        attendRuleAddDTO.setWifiList(wifiList);
//        // 打卡时间
//        attendRuleAddDTO.setPunchTimeList(punchTimeList);
//        // 特殊日期-必须打卡的日期
//        attendRuleAddDTO.setNeedPunchDateList(needPunchDateList);
//        // 特殊日期-不必打卡的日期
//        attendRuleAddDTO.setNoNeedPunchDateList(noNeedPunchDateList);
//        // 加班规则不能为空
//        attendRuleAddDTO.setOvertimeRule(overtimeRule);
//        attendRuleAddDTO.setWorkDayRuleDTO(getWorkDayRule());
//        attendRuleAddDTO.setNonWorkDayRuleDTO(getNonWorkDayRule());
//        // 是否同步中国节假日不能为空
//        attendRuleAddDTO.setIsSynchLegalHoliday(isSynchLegalHoliday);
//        // 是否手机提醒
//        attendRuleAddDTO.setIsRemind(isRemind);
//        // 上班前x分钟
//        attendRuleAddDTO.setRemindBefore(remindBefore);
//        // 下班后x分钟
//        attendRuleAddDTO.setRemindAfter(remindAfter);
//        // 员工打卡时必须拍照不能为空
//        attendRuleAddDTO.setIsTakePhoto(isTakePhoto);
//        // 只能拍照
//        attendRuleAddDTO.setIsOnlyPhoto(isOnlyPhoto);
//        // 范围外打卡
//        attendRuleAddDTO.setPunchRange(punchRange);
//        // 是否补卡申请
//        attendRuleAddDTO.setIsMakeUp(isMakeUp);
//        // 每月不高于x下次
//        attendRuleAddDTO.setMaxMakeUpCounts(maxMakeUpCounts);
//        // 生效时间
//        attendRuleAddDTO.setTakeEffect(takeEffect);
//
//        System.out.println(JSON.toJSONString(attendRuleAddDTO));
//    }

    public static WorkDayRuleDTO getWorkDayRule() {

        WorkDayRuleDTO workDayRule = new WorkDayRuleDTO();

        workDayRule.setIsWorkDay(true);
        workDayRule.setStartMinutes(2);
        workDayRule.setShortMinutes(4);
        workDayRule.setLongestMinutes(5);

        return workDayRule;
    }

    public static NonWorkDayRuleDTO getNonWorkDayRule() {

        NonWorkDayRuleDTO nonWorkDayRule = new NonWorkDayRuleDTO();

        nonWorkDayRule.setIsNonWorkDay(true);
        nonWorkDayRule.setShortMinutes(5);
        nonWorkDayRule.setLongestMinutes(7);

        return nonWorkDayRule;
    }


    /**
     * 打卡部门
     *
     * @return
     */
    public static List<AttendRuleDeptAddDTO> getDeptList() {

        List<AttendRuleDeptAddDTO> deptList = new ArrayList<>();

        // 部门一
        AttendRuleDeptAddDTO dept1 = new AttendRuleDeptAddDTO();
        dept1.setDeptId("dep1");
        dept1.setDeptName("部门一");
        deptList.add(dept1);

        // 部门二
        AttendRuleDeptAddDTO dept2 = new AttendRuleDeptAddDTO();
        dept1.setDeptId("dep2");
        dept1.setDeptName("部门二");
        deptList.add(dept2);

        return deptList;
    }

    /**
     * 打卡人员
     *
     * @return
     */
    public static List<AttendRuleStaffAddDTO> getStaffList() {

        List<AttendRuleStaffAddDTO> staffList = new ArrayList<>();

        AttendRuleStaffAddDTO staff1 = new AttendRuleStaffAddDTO();
        staff1.setDepInfoId("dep1");
        staff1.setDepInfoName("部门一");
        staff1.setEmpInfoId("emp1");
        staff1.setEmpInfoName("员工一");
        staffList.add(staff1);

        AttendRuleStaffAddDTO staff2 = new AttendRuleStaffAddDTO();
        staff2.setDepInfoId("dep2");
        staff2.setDepInfoName("部门二");
        staff2.setEmpInfoId("emp2");
        staff2.setEmpInfoName("员工二");
        staffList.add(staff2);

        AttendRuleStaffAddDTO staff3 = new AttendRuleStaffAddDTO();
        staff3.setDepInfoId("dep3");
        staff3.setDepInfoName("部门三");
        staff3.setEmpInfoId("emp3");
        staff3.setEmpInfoName("员工三");
        staffList.add(staff3);

        return staffList;
    }

    /**
     * 白名单
     *
     * @return
     */
    public static List<AttendRuleWhitelistAddDTO> getWhitelist() {

        List<AttendRuleWhitelistAddDTO> whitelist = new ArrayList<>();

        AttendRuleWhitelistAddDTO white1 = new AttendRuleWhitelistAddDTO();
        white1.setDepInfoId("dep1");
        white1.setDepInfoName("部门一");
        white1.setEmpInfoId("w1");
        white1.setEmpInfoName("员工一");
        whitelist.add(white1);

        AttendRuleWhitelistAddDTO white2 = new AttendRuleWhitelistAddDTO();
        white2.setDepInfoId("dep1");
        white2.setDepInfoName("部门一");
        white2.setEmpInfoId("w2");
        white2.setEmpInfoName("员工2");
        whitelist.add(white2);

        return whitelist;
    }

    /**
     * 汇报对象
     *
     * @return
     */
    public static List<AttendRuleReportAddDTO> getReportList() {

        List<AttendRuleReportAddDTO> reportList = new ArrayList<>();

        AttendRuleReportAddDTO report1 = new AttendRuleReportAddDTO();
        report1.setDepInfoId("dep1");
        report1.setDepInfoName("部门一");
        report1.setEmpInfoId("r1");
        report1.setEmpInfoName("小米");
        reportList.add(report1);

        AttendRuleReportAddDTO report2 = new AttendRuleReportAddDTO();
        report2.setDepInfoId("dep1");
        report2.setDepInfoName("部门一");
        report2.setEmpInfoId("r2");
        report2.setEmpInfoName("小明");
        reportList.add(report2);

        return reportList;
    }

    /**
     * 打卡地点-位置
     *
     * @return
     */
    public static List<AttendRuleLocationAddDTO> getLocationList() {

        List<AttendRuleLocationAddDTO> locationList = new ArrayList<>();

        AttendRuleLocationAddDTO local1 = new AttendRuleLocationAddDTO();
        local1.setPunchLongitude("116.644009");
        local1.setPunchLatitude("40.010055");
        local1.setPositionName("中央人民广场");
        local1.setDistance(1);
        locationList.add(local1);

        AttendRuleLocationAddDTO local2 = new AttendRuleLocationAddDTO();
        local1.setPunchLongitude("116.644009");
        local1.setPunchLatitude("40.010055");
        local2.setPositionName("中央人民广场");
        local2.setDistance(2);
        locationList.add(local2);

        return locationList;
    }

    /**
     *  打卡地点-wifi
     *
     * @return
     */
    public static List<AttendRuleWifiAddDTO> getWifiList() {

        List<AttendRuleWifiAddDTO> wifiList = new ArrayList<>();

        AttendRuleWifiAddDTO wifi1 = new AttendRuleWifiAddDTO();
        wifi1.setName("wifi1");
        wifi1.setMacAddr("xcxcxcxcxc");
        wifiList.add(wifi1);

        AttendRuleWifiAddDTO wifi2 = new AttendRuleWifiAddDTO();
        wifi2.setName("wifi2");
        wifi2.setMacAddr("xcxcxcxc");
        wifiList.add(wifi2);

        return wifiList;
    }

    /**
     * 打卡时间
     *
     * @return
     */
    public static List<AttendRulePunchTimeAddDTO> getPunchTimeList() {

        List<AttendRulePunchTimeAddDTO> punchTimeList = new ArrayList<>();

        AttendRulePunchTimeAddDTO time1 = new AttendRulePunchTimeAddDTO();
        List<String> weekList = new ArrayList<>();
        weekList.add("星期一");
        weekList.add("星期二");
        // 工作周;星期一,星期二
        time1.setWorkWeekList(weekList);

        List<AttendPeriodDTO> periodList = new ArrayList<>();

        AttendPeriodDTO attendPeriod1 = new AttendPeriodDTO();
        attendPeriod1.setStartPeriod("08:00");
        attendPeriod1.setEndPeriod("09:00");
        attendPeriod1.setType(1);
        periodList.add(attendPeriod1);

        AttendPeriodDTO attendPeriod2 = new AttendPeriodDTO();
        attendPeriod2.setStartPeriod("09:00");
        attendPeriod2.setEndPeriod("10:00");
        attendPeriod2.setType(2);
        periodList.add(attendPeriod2);

        time1.setPeriodList(periodList); // 打卡时段;80:00-12:00,13:00-18:00

        time1.setIsAllowedLateEarly(1); // 允许迟到早退；1-允许,0-不允许
        time1.setLateMinute(5); //上班允许迟到(分钟)
        time1.setEarlyMinute(5); // 下班允许早退(分钟)

        time1.setIsAllowLateLate(1); // 允许晚走晚到;1-允许,0-不允许
        time1.setOffWorkLateMinute(5); // 下班晚走(分钟)
        time1.setOnWorkLateMinute(5); // 上班晚到(分钟)

        time1.setEarliestPunchTime("80"); // 最早上班打卡时间
        time1.setLatestPunchTime("90"); // 最晚下班打卡时间(分钟)
        time1.setAfterWorkNeedPunch(1); // 下班是否需要打卡;1-是,0-否

        punchTimeList.add(time1);

        return punchTimeList;
    }

    public static List<NeedPunchDateAddDTO> getNeedPunchDateList() {

        List<NeedPunchDateAddDTO> needPunchDateList = new ArrayList<>();

        NeedPunchDateAddDTO needPunchDate1 = new NeedPunchDateAddDTO();
        needPunchDate1.setDaily("2019-12-19");

        AttendPeriodDTO attendPeriodDTO = new AttendPeriodDTO();
        attendPeriodDTO.setStartPeriod("08:00");
        attendPeriodDTO.setEndPeriod("18:00");
        attendPeriodDTO.setType(1);

        List<AttendPeriodDTO> periodList = new ArrayList<>();
        periodList.add(attendPeriodDTO);

        needPunchDate1.setPeriodList(periodList);
        needPunchDate1.setReason("xxxx");
        needPunchDateList.add(needPunchDate1);

        return needPunchDateList;
    }

    /**
     * 特殊日期-不必打卡的日期
     *
     * @return
     */
    public static List<NoNeedPunchDateAddDTO> getNoNeedPunchDateList() {

        List<NoNeedPunchDateAddDTO> noNeedPunchDateList = new ArrayList<>();

        NoNeedPunchDateAddDTO noNeedPunch1 = new NoNeedPunchDateAddDTO();
        noNeedPunch1.setDaily("2019-12-19");
        noNeedPunch1.setReason("xxxxx");

        NoNeedPunchDateAddDTO noNeedPunch2 = new NoNeedPunchDateAddDTO();
        noNeedPunch2.setDaily("2019-12-19");
        noNeedPunch2.setReason("xxxxx");

        noNeedPunchDateList.add(noNeedPunch1);
        noNeedPunchDateList.add(noNeedPunch2);

        return noNeedPunchDateList;
    }

    public static void main(String[] args) {

        AttendScheduleSaveDTO attendScheduleSaveDTO = getAttendScheduleSaveDTO();

        System.out.println(JSON.toJSONString(attendScheduleSaveDTO));

    }


    public static AttendScheduleSaveDTO getAttendScheduleSaveDTO() {

        AttendScheduleSaveDTO attendScheduleSaveDTO = new AttendScheduleSaveDTO();

        // 考勤班次
        List<AttendShiftSaveDTO> attendShiftList = getAttendShiftList();
        // 排班周期
        List<AttendCycleSaveDTO> attendCycleList = getAttendCycleList();
        // 人员排班
        List<AttendStaffScheduleDTO> attendStaffScheduleList = getAttendStaffScheduleList();

        attendScheduleSaveDTO.setAttendShiftList(attendShiftList);
        attendScheduleSaveDTO.setAttendCycleList(attendCycleList);
        attendScheduleSaveDTO.setAttendStaffScheduleList(attendStaffScheduleList);

        return attendScheduleSaveDTO;
    }

    public static List<AttendShiftSaveDTO> getAttendShiftList() {

        List<AttendShiftSaveDTO> list = new ArrayList<>();


        AttendShiftSaveDTO attendShiftSaveDTO = new AttendShiftSaveDTO();

        attendShiftSaveDTO.setName("早班");

        List<AttendPeriodDTO> attendPeriodList = new ArrayList<>();

        AttendPeriodDTO period1 = new AttendPeriodDTO();

        period1.setStartPeriod("10:00");
        period1.setEndPeriod("11:00");
        period1.setType(1);

        attendPeriodList.add(period1);

        AttendPeriodDTO period2 = new AttendPeriodDTO();

        period2.setStartPeriod("11:01");
        period2.setEndPeriod("12:00");
        period2.setType(1);

        attendPeriodList.add(period2);

        AttendPeriodDTO period3 = new AttendPeriodDTO();

        period3.setStartPeriod("13:00");
        period3.setEndPeriod("15:00");
        period3.setType(1);

        attendPeriodList.add(period3);

        AttendPeriodDTO period4 = new AttendPeriodDTO();

        period4.setStartPeriod("16:00");
        period4.setEndPeriod("18:00");
        period4.setType(1);

        attendPeriodList.add(period4);

        attendShiftSaveDTO.setAttendPeriodList(attendPeriodList);

        attendShiftSaveDTO.setIsAllowedLateEarly(1);
        attendShiftSaveDTO.setLateMinute(10);
        attendShiftSaveDTO.setEarlyMinute(10);
        attendShiftSaveDTO.setIsAllowLateLate(1);
        attendShiftSaveDTO.setOffWorkLateMinute(20);
        attendShiftSaveDTO.setOnWorkLateMinute(20);
        attendShiftSaveDTO.setEarliestPunchTime("100");
        attendShiftSaveDTO.setLatestPunchTime("100");
        attendShiftSaveDTO.setAfterWorkNeedPunch(1);

        list.add(attendShiftSaveDTO);

        return list;
    }

    public static List<AttendCycleSaveDTO> getAttendCycleList() {

        List<AttendCycleSaveDTO> list = new ArrayList<>();

        List<CycleDaysDTO> cycleDays = new ArrayList<>();

        CycleDaysDTO c1 = new CycleDaysDTO();
        c1.setDaysName("第1天");
        c1.setShiftName("早班");
        CycleDaysDTO c2 = new CycleDaysDTO();
        c2.setDaysName("第2天");
        c2.setShiftName("休");
        cycleDays.add(c1);
        cycleDays.add(c2);

        AttendCycleSaveDTO attendCycleSaveDTO = new AttendCycleSaveDTO();

        attendCycleSaveDTO.setCycleName("两日周期");
        attendCycleSaveDTO.setCycleDays(cycleDays);

        list.add(attendCycleSaveDTO);

        return list;
    }

    public static List<AttendStaffScheduleDTO> getAttendStaffScheduleList() {

        List<AttendStaffScheduleDTO> list = new ArrayList<>();

        AttendStaffScheduleDTO s1 = new AttendStaffScheduleDTO();
        s1.setShiftName("早班");
        s1.setYearMonthDay("2020-01-11");
        s1.setEmpInfoName("张三");
        s1.setEmpInfoId("1");

        AttendStaffScheduleDTO s2 = new AttendStaffScheduleDTO();
        s2.setShiftName("早班");
        s2.setYearMonthDay("2020-01-10");
        s2.setEmpInfoName("张三");
        s2.setEmpInfoId("1");

        AttendStaffScheduleDTO s3 = new AttendStaffScheduleDTO();
        s3.setShiftName("休");
        s3.setYearMonthDay("2020-01-12");
        s3.setEmpInfoName("张三");
        s3.setEmpInfoId("1");

        list.add(s1);
        list.add(s2);
        list.add(s3);

        return list;
    }




}
